package com.cdut.logistics.service.impl.datacentre;

import java.util.List;
import com.cdut.logistics.model.dao.datacentre.User;
import com.cdut.logistics.service.interf.datacentre.UserService;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;



/**  
 * @ClassName: User
 * @Description: 用户管理接口实现类  
 * @author wxt.xia
 * @date 2018年1月26日 上午9:14:27    
 */
public class UserImpl implements UserService{
	
	private User dao = new User();
	
	/**  
	 * @Title: get 
	 * @Description: 根据id查询用户
	 * @author wxt.xia
	 * @param user
	 * @throws  
	 */
	public User get(int id) {
		return dao.queryById(id);
	}
	
	/**  
	 * @Title: queryById  
	 * @Description: 根据id查询用户
	 * @author wxt.xia
	 * @param user
	 * @throws  
	 */
	public Record queryById(int id) {
		return Db.findFirst(dao.sql2,id);
	}
	
	/**  
	 * @Title: query  
	 * @Description: 根据name查询用户
	 * @author wxt.xia
	 * @param user
	 * @throws  
	 */
	public List<Record> query(String name) {
		return Db.find(dao.sql1,name);
	}

	/**  
	 * @Title: add  
	 * @Description: 新增用户
	 * @author wxt.xia
	 * @param user
	 * @throws  
	 */
	public void add(User user){
		try {
			dao.save(user);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**  
	 * @Title: modify  
	 * @Description: 修改字典值
	 * @author wxt.xia
	 * @param dept
	 * @throws  
	 */
	public void modify(User user){
		user.update();
	}
	
	/**  
	 * @Title: remove  
	 * @Description: 删除用户
	 * @author wxt.xia
	 * @param id
	 * @throws  
	 */
	public void remove(int id){
		dao.remove(id);
	}
}
